function [out] = moving_ave(x, n);
%
% filter input array x witn an n point moving average  filter
%
out = [];
if(nargin < 2)
   n = 3; % default is 3 point
end;
if(nargin < 1)
   fprintf(2, 'moving_ave: requires at least 1 input\n');
   exit;
end;
out = x;
m = ceil(n/2);
for i = m : length(x)-m
   out(i) = mean(x(i-m+1:i+m-1));
end;
return;
